<?php
session_start();
?>
<html><head>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />

</head>
<body>
<?php
include_once ("common.php");
require_once ("adminauth.php");
printAdminHeader();
?>
<br><br>
<center>
<?php
require_once ('config.php');

$con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$con) {
	die('Could not connect: ' . mysql_error());
}

mysql_select_db(DB_DATABASE, $con);

if ($_POST['member'] != NULL) {
	$sql = "update member_details set admin=NULL where userid='$_POST[member]'";
	if (mysql_query($sql)) {
	  echo "Removed $_POST[member] from Admins<br><br>";
	} else {
		die('Error: could not remove user from Admins');
	}
}

$sql = "select userid from member_details where admin is not null";

$rs = mysql_query($sql);
echo "<form name=\"form1\" method=post action=\"removeadmin.php\">
<table id=\"form\">
<tr><td><a>Admin members: </a></td><td><select name=\"member\" >
";

while ($row = mysql_fetch_array($rs)) {
	echo "<option value=\"" . $row['userid'] . "\">" . $row['userid'] . "\n  ";

}
?>
</select>
</td></tr>
<tr><td/><td><input type="submit" value="Remove Admin"/></td></tr>
</table>
<br><br>

</center>

</form>
</body>
</html>